<!-- 试试index.vue如何识别 -->
<template>
  <div class='returnsManagement'>
    <!-- 顶部筛选条件 -->
    <div>
      <a-radio-group v-model="ListType"
                     size="large" @change="change">
     <!--   <a-radio-button value="">
          全部申请（{{listLength.allCount}}）
        </a-radio-button>
        <a-radio-button value="TO_AUDIT">
          待处理（{{listLength.toAudit}}）
        </a-radio-button>
        <a-radio-button value="WAITING_GOODS">
          退货中{{listLength.repairsCount}}）
        </a-radio-button>
        <a-radio-button value="REFUND_FINISH">
          已完成（{{listLength.refundFinishCount}}）
        </a-radio-button>
        <a-radio-button value="REVIEW_FAILED">
          已拒绝（{{listLength.reviewFatledCount}}）
        </a-radio-button>-->
        <a-radio-button value="">
          全部申请（{{listLength.orderCount}}）
        </a-radio-button>
        <a-radio-button value="1">
          待处理（{{listLength.auditCount}}）
        </a-radio-button>
        <a-radio-button value="2">
          换货中（{{listLength.exchangeGoodsCount}}）
        </a-radio-button>
        <a-radio-button value="3">
          已完成（{{listLength.completedCount}}）
        </a-radio-button>
        <a-radio-button value="4">
          已拒绝（{{listLength.refusedCount}}）
        </a-radio-button>
      </a-radio-group>
    </div>
    <!-- 列表 -->

    <search-form-table :url="url"
                       ref="searchtable"
                       :hideSelect="true"
                       :columns="columns"
                       :form="form"
                       style="margin-top:20px;"
                       :ListType='ListType'>

      <template slot="searchForm">
        <a-form layout="inline"
                :form="form">
          <a-form-item label="退货单号">
            <a-input v-decorator="['id']"
                     placeholder="请输入退货单号"> </a-input>
          </a-form-item>

          <a-form-item label="收货人">
            <a-input v-decorator="['consignee']"
                     placeholder="收货人手机号/姓名"> </a-input>
          </a-form-item>

          <a-form-item label="申请时间">
            <fast-range-picker
              v-decorator="[
                'startDate-endDate',
              ]"
            >
            </fast-range-picker>
          </a-form-item>
        </a-form>
      </template>


      <template slot="tableOperation" slot-scope="{ record }">
        <permission authority="">
          <span class="text-primary pointer"
                @click="openInfo(record)">查看详情</span>
        </permission>
      </template>

    </search-form-table>
  </div>
</template>

<script>
  import SearchFormTable from "./SearchTable/index";

  export default {
    name: '',
    components: {
      SearchFormTable
    },
    directives: {},
    filters: {},
    mixins: [],
    model: {},
    props: {},
    data() {
      return {
        total:0,
        ListType:'',
        // 各类数据长度
        listLength:{},
        // url: '/order/goodsrepairs/page',
        url: 'goldenhome/gh/integral/mall/admin_/swap/order/page',
        currentRecord: {},
        form: this.$form.createForm(this, { name: 'table_search' }),
        columns: [
          {
            title: '退货单号',
            dataIndex: 'id',
            key: 'id',
            align: 'center',
          },
          {
            title: '申请时间',
            dataIndex: 'createDate',
            key: 'createDate'
          },
          {
            title: '用户账号',
            dataIndex: 'phone',
            key: 'phone'
          },
          {
            title: '支付方式',
            dataIndex: 'paymentWay',
            key: 'paymentWay',
            align: "center",
            customRender: (text, row) => {
              // console.log("text", text);
              switch (text) {
                case 1:
                  return '积分'
                case 2:
                  return '现金+积分'
                // case 3:

              }
            },
          },
          {
            title: '联系人',
            dataIndex: 'contactName',
            key: 'contactName'
          },
          {
            title: '申请状态',
            dataIndex: 'swapGoodsStatus',
            key: 'swapGoodsStatus',
            customRender: (text, row) => {
              switch (text) {
                case 'TO_AUDIT':
                  return '待处理'
                case 'USER_CANCEL':
                  return '撤销申请'

                case 'REVIEW_FAILED':
                  return '拒绝换货'

                case 'APPROVE_AUDIT':
                  return '审核通过'

                case 'BUYER_SEND_BACK':
                  return '买家寄回中'

               /* case 'WAITING_GOODS':
                  return '退货中'
*/
                case 'RECEIVED_GOODS':
                  return '卖家已收货'

                case 'AGAIN_DELIVER_GOODS':
                  return '卖家已重发货'

                case 'EXCHANGE_GOODS_FINISH':
                  return '换货成功'



              }
            },
          },
          {
            title: '处理时间',
            dataIndex: 'updateDate',
            key: 'updateDate',
          },
          {
            title: '操作',
            dataIndex: 'operation',
            scopedSlots: { customRender: 'operation' }
          }
        ]
      }
    },
    computed: {

    },
    watch: {},
    beforeCreate() {},

    created() {
      this.getItemsLength()

    },

    // 方法集合
    methods: {

      change(){
        this.$refs.searchtable.handleSearch()
      },

      openInfo(record) {
        console.log('当前行数据:',record)
        this.currentRecord = record
        this.$router.push({
          name: 'OrderReturnsExchangeManagementInfo',
          query: {
            id: record.id,
            // applyStatus:record.swapGoodsStatus
            // applyStatus:record.returnGoodsStatus
          }
        })
      },

      // 获取各类数据个数
      async getItemsLength(){
        // const res = await this.$get('/order/goodsrepairs/total?repairsType=2')
        const res = await this.$get('goldenhome/gh/integral/mall/admin_/swap/order/orderCount')

        this.listLength = res.dataInfo
      }
    }
  }
</script>
<style rel='stylesheet/less' lang='less' scoped>
  //@import url();
</style>
